// 公共JS
function ymdhis(){
    let date = new Date();
    //获取年份
    let year = date.getFullYear();
    //获取月份
    let month = date.getMonth()+1;
    //获取日期
    let day = date.getDate();
    //获取小时
    let hour = date.getHours();
    hour = hour<10 ? '0'+hour:hour;
    //获取分钟
    let minute = date.getMinutes();
    minute = minute<10 ? '0'+minute:minute;
    //获取秒
    let second = date.getSeconds();
    second = second<10 ? '0'+second:second;
    document.querySelector('.year').innerHTML = year;
    document.querySelector('.month').innerHTML = month;
    document.querySelector('.day').innerHTML = day;
    document.querySelector('.hour').innerHTML = hour;
    document.querySelector('.minute').innerHTML = minute;
    document.querySelector('.second').innerHTML = second;
}
ymdhis();
//闹钟定时器
setInterval(ymdhis,1000);

//点击学校概况，切换大小图
document.querySelector('#party_title_room').onclick=function(e){
    //有5张图
    let randnum = getRandomIntInclusive(1,5);//[1,5]
    var bigImg = document.querySelector('#center_change_pic');
    var smallImg = document.querySelector('#smallPic');
    //big-01.jpg
    let bigPath = 'images/big-0'+randnum+".jpg";
    //small-01.jpg
    let smallPath = 'images/small-0'+randnum+'.jpg';
    bigImg.style.background="url("+bigPath+")";
    bigImg.style.backgroundSize = 'cover';
    smallImg.src=smallPath;
}
function getRandomIntInclusive(min, max) {
    min = Math.ceil(min);
    max = Math.floor(max);
    return Math.floor(Math.random() * (max - min + 1)) + min; //含最大值，含最小值 
}

/**
 * 
 * @param {参数名字} param 
 */
function getLoctionParam(param){
    //window.location.search  ?aid=7&cid=20
    let loction = window.location.search.substring(1);//aid=7&cid=20
    //将字符串转为数组
    let params = loction.split('&');//Array [ "aid=7", "cid=20" ]
    //循环
    if(params.length>0){
        for(var i=0;i<params.length;i++){
            //假定取一个"aid=7"或"cid=20"
            let signal = params[i];
            let signalArr = signal.split('=');
            if(signalArr[0]==param){
                return signalArr[1];
            }
        }
    }
    return false;
}
let aid = getLoctionParam('aid');
console.log(aid);